<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Validators &mdash; Django 1.7.8.dev20150401230226 documentation</title>
    
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.7.8.dev20150401230226',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="Django 1.7.8.dev20150401230226 documentation" href="../index.html" />
    <link rel="up" title="API Reference" href="index.html" />
    <link rel="next" title="Built-in Views" href="views.html" />
    <link rel="prev" title="Django Utils" href="utils.html" />



 
<script type="text/javascript" src="../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head>
  <body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 1.7.8.dev20150401230226 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../index.html">Home</a>  |
        <a title="Table of contents" href="../contents.html">Table of contents</a>  |
        <a title="Global index" href="../genindex.html">Index</a>  |
        <a title="Module index" href="../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="utils.html" title="Django Utils">previous</a>
     |
    <a href="index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="views.html" title="Built-in Views">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-validators">
            
  <div class="section" id="s-module-django.core.validators">
<span id="s-validators"></span><span id="module-django.core.validators"></span><span id="validators"></span><h1>Validators<a class="headerlink" href="#module-django.core.validators" title="Permalink to this headline">¶</a></h1>
<div class="section" id="s-writing-validators">
<span id="writing-validators"></span><h2>Writing validators<a class="headerlink" href="#writing-validators" title="Permalink to this headline">¶</a></h2>
<p>A validator is a callable that takes a value and raises a
<a class="reference internal" href="exceptions.html#django.core.exceptions.ValidationError" title="django.core.exceptions.ValidationError"><tt class="xref py py-exc docutils literal"><span class="pre">ValidationError</span></tt></a> if it doesn&#8217;t meet some
criteria. Validators can be useful for re-using validation logic between
different types of fields.</p>
<p>For example, here&#8217;s a validator that only allows even numbers:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.core.exceptions</span> <span class="kn">import</span> <span class="n">ValidationError</span>

<span class="k">def</span> <span class="nf">validate_even</span><span class="p">(</span><span class="n">value</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">value</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
        <span class="k">raise</span> <span class="n">ValidationError</span><span class="p">(</span><span class="s">u&#39;</span><span class="si">%s</span><span class="s"> is not an even number&#39;</span> <span class="o">%</span> <span class="n">value</span><span class="p">)</span>
</pre></div>
</div>
<p>You can add this to a model field via the field&#8217;s <a class="reference internal" href="models/fields.html#django.db.models.Field.validators" title="django.db.models.Field.validators"><tt class="xref py py-attr docutils literal"><span class="pre">validators</span></tt></a>
argument:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.db</span> <span class="kn">import</span> <span class="n">models</span>

<span class="k">class</span> <span class="nc">MyModel</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">even_field</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">IntegerField</span><span class="p">(</span><span class="n">validators</span><span class="o">=</span><span class="p">[</span><span class="n">validate_even</span><span class="p">])</span>
</pre></div>
</div>
<p>Because values are converted to Python before validators are run, you can even
use the same validator with forms:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">forms</span>

<span class="k">class</span> <span class="nc">MyForm</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">Form</span><span class="p">):</span>
    <span class="n">even_field</span> <span class="o">=</span> <span class="n">forms</span><span class="o">.</span><span class="n">IntegerField</span><span class="p">(</span><span class="n">validators</span><span class="o">=</span><span class="p">[</span><span class="n">validate_even</span><span class="p">])</span>
</pre></div>
</div>
<p>You can also use a class with a <tt class="docutils literal"><span class="pre">__call__()</span></tt> method for more complex or
configurable validators. <a class="reference internal" href="#django.core.validators.RegexValidator" title="django.core.validators.RegexValidator"><tt class="xref py py-class docutils literal"><span class="pre">RegexValidator</span></tt></a>, for example, uses this
technique. If a class-based validator is used in the
<a class="reference internal" href="models/fields.html#django.db.models.Field.validators" title="django.db.models.Field.validators"><tt class="xref py py-attr docutils literal"><span class="pre">validators</span></tt></a> model field option, you should make
sure it is <a class="reference internal" href="../topics/migrations.html#migration-serializing"><em>serializable by the migration framework</em></a> by adding <a class="reference internal" href="../topics/migrations.html#custom-deconstruct-method"><em>deconstruct()</em></a> and <tt class="docutils literal"><span class="pre">__eq__()</span></tt> methods.</p>
</div>
<div class="section" id="s-how-validators-are-run">
<span id="how-validators-are-run"></span><h2>How validators are run<a class="headerlink" href="#how-validators-are-run" title="Permalink to this headline">¶</a></h2>
<p>See the <a class="reference internal" href="forms/validation.html"><em>form validation</em></a> for more information on
how validators are run in forms, and <a class="reference internal" href="models/instances.html#validating-objects"><em>Validating objects</em></a> for how they&#8217;re run in models. Note that validators will
not be run automatically when you save a model, but if you are using a
<a class="reference internal" href="../topics/forms/modelforms.html#django.forms.ModelForm" title="django.forms.ModelForm"><tt class="xref py py-class docutils literal"><span class="pre">ModelForm</span></tt></a>, it will run your validators on any fields
that are included in your form. See the
<a class="reference internal" href="../topics/forms/modelforms.html"><em>ModelForm documentation</em></a> for information on
how model validation interacts with forms.</p>
</div>
<div class="section" id="s-built-in-validators">
<span id="built-in-validators"></span><h2>Built-in validators<a class="headerlink" href="#built-in-validators" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#module-django.core.validators" title="django.core.validators: Validation utilities and base classes"><tt class="xref py py-mod docutils literal"><span class="pre">django.core.validators</span></tt></a> module contains a collection of callable
validators for use with model and form fields. They&#8217;re used internally but
are available for use with your own fields, too. They can be used in addition
to, or in lieu of custom <tt class="docutils literal"><span class="pre">field.clean()</span></tt> methods.</p>
<div class="section" id="s-regexvalidator">
<span id="regexvalidator"></span><h3><tt class="docutils literal"><span class="pre">RegexValidator</span></tt><a class="headerlink" href="#regexvalidator" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.core.validators.RegexValidator">
<em class="property">class </em><tt class="descname">RegexValidator</tt>(<span class="optional">[</span><em>regex=None</em>, <em>message=None</em>, <em>code=None</em>, <em>inverse_match=None</em>, <em>flags=0</em><span class="optional">]</span>)<a class="reference internal" href="../_modules/django/core/validators.html#RegexValidator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.validators.RegexValidator" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>regex</strong> &#8211; If not <tt class="docutils literal"><span class="pre">None</span></tt>, overrides <a class="reference internal" href="#django.core.validators.RegexValidator.regex" title="django.core.validators.RegexValidator.regex"><tt class="xref py py-attr docutils literal"><span class="pre">regex</span></tt></a>. Can be a regular
expression string or a pre-compiled regular expression.</li>
<li><strong>message</strong> &#8211; If not <tt class="docutils literal"><span class="pre">None</span></tt>, overrides <a class="reference internal" href="#django.core.validators.RegexValidator.message" title="django.core.validators.RegexValidator.message"><tt class="xref py py-attr docutils literal"><span class="pre">message</span></tt></a>.</li>
<li><strong>code</strong> &#8211; If not <tt class="docutils literal"><span class="pre">None</span></tt>, overrides <a class="reference internal" href="#django.core.validators.RegexValidator.code" title="django.core.validators.RegexValidator.code"><tt class="xref py py-attr docutils literal"><span class="pre">code</span></tt></a>.</li>
<li><strong>inverse_match</strong> &#8211; If not <tt class="docutils literal"><span class="pre">None</span></tt>, overrides <a class="reference internal" href="#django.core.validators.RegexValidator.inverse_match" title="django.core.validators.RegexValidator.inverse_match"><tt class="xref py py-attr docutils literal"><span class="pre">inverse_match</span></tt></a>.</li>
<li><strong>flags</strong> &#8211; If not <tt class="docutils literal"><span class="pre">None</span></tt>, overrides <a class="reference internal" href="#django.core.validators.RegexValidator.flags" title="django.core.validators.RegexValidator.flags"><tt class="xref py py-attr docutils literal"><span class="pre">flags</span></tt></a>. In that case,
<a class="reference internal" href="#django.core.validators.RegexValidator.regex" title="django.core.validators.RegexValidator.regex"><tt class="xref py py-attr docutils literal"><span class="pre">regex</span></tt></a> must be a regular expression string, or
<a class="reference external" href="http://docs.python.org/3/library/exceptions.html#TypeError" title="(in Python v3.4)"><tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt></a> is raised.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="django.core.validators.RegexValidator.regex">
<tt class="descname">regex</tt><a class="headerlink" href="#django.core.validators.RegexValidator.regex" title="Permalink to this definition">¶</a></dt>
<dd><p>The regular expression pattern to search for the provided <tt class="docutils literal"><span class="pre">value</span></tt>,
or a pre-compiled regular expression. By default, raises a
<a class="reference internal" href="exceptions.html#django.core.exceptions.ValidationError" title="django.core.exceptions.ValidationError"><tt class="xref py py-exc docutils literal"><span class="pre">ValidationError</span></tt></a> with <a class="reference internal" href="#django.core.validators.RegexValidator.message" title="django.core.validators.RegexValidator.message"><tt class="xref py py-attr docutils literal"><span class="pre">message</span></tt></a>
and <a class="reference internal" href="#django.core.validators.RegexValidator.code" title="django.core.validators.RegexValidator.code"><tt class="xref py py-attr docutils literal"><span class="pre">code</span></tt></a> if a match is not found. That standard behavior can
be reversed by setting <a class="reference internal" href="#django.core.validators.RegexValidator.inverse_match" title="django.core.validators.RegexValidator.inverse_match"><tt class="xref py py-attr docutils literal"><span class="pre">inverse_match</span></tt></a> to <tt class="docutils literal"><span class="pre">True</span></tt>, in which case
the <a class="reference internal" href="exceptions.html#django.core.exceptions.ValidationError" title="django.core.exceptions.ValidationError"><tt class="xref py py-exc docutils literal"><span class="pre">ValidationError</span></tt></a> is raised when a
match <strong>is</strong> found. By default, matches any string (including an empty
string).</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.validators.RegexValidator.message">
<tt class="descname">message</tt><a class="headerlink" href="#django.core.validators.RegexValidator.message" title="Permalink to this definition">¶</a></dt>
<dd><p>The error message used by
<a class="reference internal" href="exceptions.html#django.core.exceptions.ValidationError" title="django.core.exceptions.ValidationError"><tt class="xref py py-exc docutils literal"><span class="pre">ValidationError</span></tt></a> if validation fails.
Defaults to <tt class="docutils literal"><span class="pre">&quot;Enter</span> <span class="pre">a</span> <span class="pre">valid</span> <span class="pre">value&quot;</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.validators.RegexValidator.code">
<tt class="descname">code</tt><a class="headerlink" href="#django.core.validators.RegexValidator.code" title="Permalink to this definition">¶</a></dt>
<dd><p>The error code used by <a class="reference internal" href="exceptions.html#django.core.exceptions.ValidationError" title="django.core.exceptions.ValidationError"><tt class="xref py py-exc docutils literal"><span class="pre">ValidationError</span></tt></a>
if validation fails. Defaults to <tt class="docutils literal"><span class="pre">&quot;invalid&quot;</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.validators.RegexValidator.inverse_match">
<tt class="descname">inverse_match</tt><a class="headerlink" href="#django.core.validators.RegexValidator.inverse_match" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.7.</span> </div>
<p>The match mode for <a class="reference internal" href="#django.core.validators.RegexValidator.regex" title="django.core.validators.RegexValidator.regex"><tt class="xref py py-attr docutils literal"><span class="pre">regex</span></tt></a>. Defaults to <tt class="docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.validators.RegexValidator.flags">
<tt class="descname">flags</tt><a class="headerlink" href="#django.core.validators.RegexValidator.flags" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.7.</span> </div>
<p>The flags used when compiling the regular expression string <a class="reference internal" href="#django.core.validators.RegexValidator.regex" title="django.core.validators.RegexValidator.regex"><tt class="xref py py-attr docutils literal"><span class="pre">regex</span></tt></a>.
If <a class="reference internal" href="#django.core.validators.RegexValidator.regex" title="django.core.validators.RegexValidator.regex"><tt class="xref py py-attr docutils literal"><span class="pre">regex</span></tt></a> is a pre-compiled regular expression, and <a class="reference internal" href="#django.core.validators.RegexValidator.flags" title="django.core.validators.RegexValidator.flags"><tt class="xref py py-attr docutils literal"><span class="pre">flags</span></tt></a> is overridden,
<a class="reference external" href="http://docs.python.org/3/library/exceptions.html#TypeError" title="(in Python v3.4)"><tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt></a> is raised.
Defaults to <cite>0</cite>.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="s-urlvalidator">
<span id="urlvalidator"></span><h3><tt class="docutils literal"><span class="pre">URLValidator</span></tt><a class="headerlink" href="#urlvalidator" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.core.validators.URLValidator">
<em class="property">class </em><tt class="descname">URLValidator</tt>(<span class="optional">[</span><em>schemes=None</em>, <em>regex=None</em>, <em>message=None</em>, <em>code=None</em><span class="optional">]</span>)<a class="reference internal" href="../_modules/django/core/validators.html#URLValidator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.validators.URLValidator" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#django.core.validators.RegexValidator" title="django.core.validators.RegexValidator"><tt class="xref py py-class docutils literal"><span class="pre">RegexValidator</span></tt></a> that ensures a value looks like a URL, and raises
an error code of <tt class="docutils literal"><span class="pre">'invalid'</span></tt> if it doesn&#8217;t. In addition to the optional
arguments of its parent <a class="reference internal" href="#django.core.validators.RegexValidator" title="django.core.validators.RegexValidator"><tt class="xref py py-class docutils literal"><span class="pre">RegexValidator</span></tt></a> class, <tt class="docutils literal"><span class="pre">URLValidator</span></tt>
accepts an extra optional attribute:</p>
<dl class="attribute">
<dt id="django.core.validators.URLValidator.schemes">
<tt class="descname">schemes</tt><a class="headerlink" href="#django.core.validators.URLValidator.schemes" title="Permalink to this definition">¶</a></dt>
<dd><p>URL/URI scheme list to validate against. If not provided, the default
list is <tt class="docutils literal"><span class="pre">['http',</span> <span class="pre">'https',</span> <span class="pre">'ftp',</span> <span class="pre">'ftps']</span></tt>. As a reference, the IANA
Web site provides a full list of <a class="reference external" href="https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml">valid URI schemes</a>.</p>
</dd></dl>

<div class="versionchanged">
<span class="title">Changed in Django 1.7:</span> <p>The optional <tt class="docutils literal"><span class="pre">schemes</span></tt> attribute was added.</p>
</div>
</dd></dl>

</div>
<div class="section" id="s-validate-email">
<span id="validate-email"></span><h3><tt class="docutils literal"><span class="pre">validate_email</span></tt><a class="headerlink" href="#validate-email" title="Permalink to this headline">¶</a></h3>
<dl class="data">
<dt id="django.core.validators.validate_email">
<tt class="descname">validate_email</tt><a class="headerlink" href="#django.core.validators.validate_email" title="Permalink to this definition">¶</a></dt>
<dd><p>An <tt class="docutils literal"><span class="pre">EmailValidator</span></tt> instance that ensures a value looks like an
email address.</p>
</dd></dl>

</div>
<div class="section" id="s-validate-slug">
<span id="validate-slug"></span><h3><tt class="docutils literal"><span class="pre">validate_slug</span></tt><a class="headerlink" href="#validate-slug" title="Permalink to this headline">¶</a></h3>
<dl class="data">
<dt id="django.core.validators.validate_slug">
<tt class="descname">validate_slug</tt><a class="headerlink" href="#django.core.validators.validate_slug" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#django.core.validators.RegexValidator" title="django.core.validators.RegexValidator"><tt class="xref py py-class docutils literal"><span class="pre">RegexValidator</span></tt></a> instance that ensures a value consists of only
letters, numbers, underscores or hyphens.</p>
</dd></dl>

</div>
<div class="section" id="s-validate-ipv4-address">
<span id="validate-ipv4-address"></span><h3><tt class="docutils literal"><span class="pre">validate_ipv4_address</span></tt><a class="headerlink" href="#validate-ipv4-address" title="Permalink to this headline">¶</a></h3>
<dl class="data">
<dt id="django.core.validators.validate_ipv4_address">
<tt class="descname">validate_ipv4_address</tt><a class="headerlink" href="#django.core.validators.validate_ipv4_address" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#django.core.validators.RegexValidator" title="django.core.validators.RegexValidator"><tt class="xref py py-class docutils literal"><span class="pre">RegexValidator</span></tt></a> instance that ensures a value looks like an IPv4
address.</p>
</dd></dl>

</div>
<div class="section" id="s-validate-ipv6-address">
<span id="validate-ipv6-address"></span><h3><tt class="docutils literal"><span class="pre">validate_ipv6_address</span></tt><a class="headerlink" href="#validate-ipv6-address" title="Permalink to this headline">¶</a></h3>
<dl class="data">
<dt id="django.core.validators.validate_ipv6_address">
<tt class="descname">validate_ipv6_address</tt><a class="reference internal" href="../_modules/django/core/validators.html#validate_ipv6_address"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.validators.validate_ipv6_address" title="Permalink to this definition">¶</a></dt>
<dd><p>Uses <tt class="docutils literal"><span class="pre">django.utils.ipv6</span></tt> to check the validity of an IPv6 address.</p>
</dd></dl>

</div>
<div class="section" id="s-validate-ipv46-address">
<span id="validate-ipv46-address"></span><h3><tt class="docutils literal"><span class="pre">validate_ipv46_address</span></tt><a class="headerlink" href="#validate-ipv46-address" title="Permalink to this headline">¶</a></h3>
<dl class="data">
<dt id="django.core.validators.validate_ipv46_address">
<tt class="descname">validate_ipv46_address</tt><a class="reference internal" href="../_modules/django/core/validators.html#validate_ipv46_address"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.validators.validate_ipv46_address" title="Permalink to this definition">¶</a></dt>
<dd><p>Uses both <tt class="docutils literal"><span class="pre">validate_ipv4_address</span></tt> and <tt class="docutils literal"><span class="pre">validate_ipv6_address</span></tt> to
ensure a value is either a valid IPv4 or IPv6 address.</p>
</dd></dl>

</div>
<div class="section" id="s-validate-comma-separated-integer-list">
<span id="validate-comma-separated-integer-list"></span><h3><tt class="docutils literal"><span class="pre">validate_comma_separated_integer_list</span></tt><a class="headerlink" href="#validate-comma-separated-integer-list" title="Permalink to this headline">¶</a></h3>
<dl class="data">
<dt id="django.core.validators.validate_comma_separated_integer_list">
<tt class="descname">validate_comma_separated_integer_list</tt><a class="headerlink" href="#django.core.validators.validate_comma_separated_integer_list" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#django.core.validators.RegexValidator" title="django.core.validators.RegexValidator"><tt class="xref py py-class docutils literal"><span class="pre">RegexValidator</span></tt></a> instance that ensures a value is a
comma-separated list of integers.</p>
</dd></dl>

</div>
<div class="section" id="s-maxvaluevalidator">
<span id="maxvaluevalidator"></span><h3><tt class="docutils literal"><span class="pre">MaxValueValidator</span></tt><a class="headerlink" href="#maxvaluevalidator" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.core.validators.MaxValueValidator">
<em class="property">class </em><tt class="descname">MaxValueValidator</tt>(<em>max_value</em>)<a class="reference internal" href="../_modules/django/core/validators.html#MaxValueValidator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.validators.MaxValueValidator" title="Permalink to this definition">¶</a></dt>
<dd><p>Raises a <a class="reference internal" href="exceptions.html#django.core.exceptions.ValidationError" title="django.core.exceptions.ValidationError"><tt class="xref py py-exc docutils literal"><span class="pre">ValidationError</span></tt></a> with a code of
<tt class="docutils literal"><span class="pre">'max_value'</span></tt> if <tt class="docutils literal"><span class="pre">value</span></tt> is greater than <tt class="docutils literal"><span class="pre">max_value</span></tt>.</p>
</dd></dl>

</div>
<div class="section" id="s-minvaluevalidator">
<span id="minvaluevalidator"></span><h3><tt class="docutils literal"><span class="pre">MinValueValidator</span></tt><a class="headerlink" href="#minvaluevalidator" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.core.validators.MinValueValidator">
<em class="property">class </em><tt class="descname">MinValueValidator</tt>(<em>min_value</em>)<a class="reference internal" href="../_modules/django/core/validators.html#MinValueValidator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.validators.MinValueValidator" title="Permalink to this definition">¶</a></dt>
<dd><p>Raises a <a class="reference internal" href="exceptions.html#django.core.exceptions.ValidationError" title="django.core.exceptions.ValidationError"><tt class="xref py py-exc docutils literal"><span class="pre">ValidationError</span></tt></a> with a code of
<tt class="docutils literal"><span class="pre">'min_value'</span></tt> if <tt class="docutils literal"><span class="pre">value</span></tt> is less than <tt class="docutils literal"><span class="pre">min_value</span></tt>.</p>
</dd></dl>

</div>
<div class="section" id="s-maxlengthvalidator">
<span id="maxlengthvalidator"></span><h3><tt class="docutils literal"><span class="pre">MaxLengthValidator</span></tt><a class="headerlink" href="#maxlengthvalidator" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.core.validators.MaxLengthValidator">
<em class="property">class </em><tt class="descname">MaxLengthValidator</tt>(<em>max_length</em>)<a class="reference internal" href="../_modules/django/core/validators.html#MaxLengthValidator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.validators.MaxLengthValidator" title="Permalink to this definition">¶</a></dt>
<dd><p>Raises a <a class="reference internal" href="exceptions.html#django.core.exceptions.ValidationError" title="django.core.exceptions.ValidationError"><tt class="xref py py-exc docutils literal"><span class="pre">ValidationError</span></tt></a> with a code of
<tt class="docutils literal"><span class="pre">'max_length'</span></tt> if the length of <tt class="docutils literal"><span class="pre">value</span></tt> is greater than <tt class="docutils literal"><span class="pre">max_length</span></tt>.</p>
</dd></dl>

</div>
<div class="section" id="s-minlengthvalidator">
<span id="minlengthvalidator"></span><h3><tt class="docutils literal"><span class="pre">MinLengthValidator</span></tt><a class="headerlink" href="#minlengthvalidator" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.core.validators.MinLengthValidator">
<em class="property">class </em><tt class="descname">MinLengthValidator</tt>(<em>min_length</em>)<a class="reference internal" href="../_modules/django/core/validators.html#MinLengthValidator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.validators.MinLengthValidator" title="Permalink to this definition">¶</a></dt>
<dd><p>Raises a <a class="reference internal" href="exceptions.html#django.core.exceptions.ValidationError" title="django.core.exceptions.ValidationError"><tt class="xref py py-exc docutils literal"><span class="pre">ValidationError</span></tt></a> with a code of
<tt class="docutils literal"><span class="pre">'min_length'</span></tt> if the length of <tt class="docutils literal"><span class="pre">value</span></tt> is less than <tt class="docutils literal"><span class="pre">min_length</span></tt>.</p>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Validators</a><ul>
<li><a class="reference internal" href="#writing-validators">Writing validators</a></li>
<li><a class="reference internal" href="#how-validators-are-run">How validators are run</a></li>
<li><a class="reference internal" href="#built-in-validators">Built-in validators</a><ul>
<li><a class="reference internal" href="#regexvalidator"><tt class="docutils literal"><span class="pre">RegexValidator</span></tt></a></li>
<li><a class="reference internal" href="#urlvalidator"><tt class="docutils literal"><span class="pre">URLValidator</span></tt></a></li>
<li><a class="reference internal" href="#validate-email"><tt class="docutils literal"><span class="pre">validate_email</span></tt></a></li>
<li><a class="reference internal" href="#validate-slug"><tt class="docutils literal"><span class="pre">validate_slug</span></tt></a></li>
<li><a class="reference internal" href="#validate-ipv4-address"><tt class="docutils literal"><span class="pre">validate_ipv4_address</span></tt></a></li>
<li><a class="reference internal" href="#validate-ipv6-address"><tt class="docutils literal"><span class="pre">validate_ipv6_address</span></tt></a></li>
<li><a class="reference internal" href="#validate-ipv46-address"><tt class="docutils literal"><span class="pre">validate_ipv46_address</span></tt></a></li>
<li><a class="reference internal" href="#validate-comma-separated-integer-list"><tt class="docutils literal"><span class="pre">validate_comma_separated_integer_list</span></tt></a></li>
<li><a class="reference internal" href="#maxvaluevalidator"><tt class="docutils literal"><span class="pre">MaxValueValidator</span></tt></a></li>
<li><a class="reference internal" href="#minvaluevalidator"><tt class="docutils literal"><span class="pre">MinValueValidator</span></tt></a></li>
<li><a class="reference internal" href="#maxlengthvalidator"><tt class="docutils literal"><span class="pre">MaxLengthValidator</span></tt></a></li>
<li><a class="reference internal" href="#minlengthvalidator"><tt class="docutils literal"><span class="pre">MinLengthValidator</span></tt></a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h3>Browse</h3>
  <ul>
    
      <li>Prev: <a href="utils.html">Django Utils</a></li>
    
    
      <li>Next: <a href="views.html">Built-in Views</a></li>
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../index.html">Django 1.7.8.dev20150401230226 documentation</a>
        
          <ul><li><a href="index.html">API Reference</a>
        
        <ul><li>Validators</li></ul>
        </li></ul>
      </li>
  </ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/ref/validators.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Apr 02, 2015</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="utils.html" title="Django Utils">previous</a>
     |
    <a href="index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="views.html" title="Built-in Views">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>